package com.sphd.beautysalon.model;


import com.android.volley.VolleyError;
import com.sphd.beautysalon.interfaces.VolleyJsonObjectCallBack;
import com.sphd.beautysalon.presenter.AddOrderPresenterImpl;

import org.json.JSONException;
import org.json.JSONObject;

/**
* Created by Hu on 2016/12/06
*/

public class AddOrderModelImpl implements AddOrderModel, VolleyJsonObjectCallBack {
    AddOrderPresenterImpl addOrderPresenter;

    @Override
    public void sendUrl(String url, AddOrderPresenterImpl addOrderPresenter) {
        this.addOrderPresenter=addOrderPresenter;
        volleyUtil.setJsonObjectRequest(url,this);
    }

    @Override
    public void onResponse(JSONObject response) {
        try {
            int res=response.getInt("res");
            addOrderPresenter.recRes(res);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onErrorResponse(VolleyError error) {
            addOrderPresenter.sendError(error);
    }
}